home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / shell / xd-2.08 / xd-2 / xd / Config / config.cc next >
Encoding:
C/C++ Source or Header  |  1994-08-30  |  1.3 KB  |  50 lines

  1. #include "Config.h"
  2.  
  3. Config::Config()
  4. {
  5.     char
  6.     buffer[512];
  7.  
  8.     if (!(home = getenv("HOME")))        // HOME not found
  9.     home = strdup("/");            // use root's HOME
  10.     else
  11.     {
  12.     strcpy(buffer, home);
  13.     strcat(buffer, "/");            // append / to home
  14.     home = strdup(buffer);            // local home copy
  15.     }
  16.                         // Make first estimate
  17.     strcat(strcpy(buffer, home), XD_CONF_PATH); // of config file
  18.  
  19.     if (access(buffer, R_OK))            // can't read the file
  20.     strcpy(buffer, XD_CONF_PATH);        // use default file
  21.         
  22.     ConfigFile
  23.     cf(buffer);                // Read the file
  24.     char
  25.     const *token;
  26.     
  27.     homeparam =
  28.     (token = cf.get_param("HOME"))        // home parameter found ?
  29.     &&
  30.     !strcasecmp(token, "no") ?        // and it's no
  31.         from_the_root            // use from the root
  32.     :
  33.         from_HOME;                // otherwise from HOME.
  34.  
  35.     if (homeparam == from_HOME)            // search from HOME
  36.     {
  37.     extraparam = double_search;        // assume by default double search
  38.  
  39.     if (token = cf.get_param("EXTRA"))  // 'extra' parameter found ?
  40.     {
  41.         if (!strcasecmp(token, "no"))    // If the user requests 'no'
  42.         extraparam = single_search;  // use single search
  43.         else if (!strcasecmp(token, "always"))   // it's 'always' ?
  44.         extraparam = full_search;         // use allways full search
  45.     }
  46.     }
  47.     else
  48.     extraparam = single_search;        // single search if not from HOME
  49. }
  50.